package com.wanho.qz103.hrsaas.sys.service.impl;

import com.wanho.qz103.hrsaas.commons.annontations.Autowired;
import com.wanho.qz103.hrsaas.commons.annontations.Service;
import com.wanho.qz103.hrsaas.commons.annontations.Transactional;
import com.wanho.qz103.hrsaas.commons.exception.DAOException;
import com.wanho.qz103.hrsaas.commons.exception.ServiceException;
import com.wanho.qz103.hrsaas.sys.dao.EmployeeDAO;
import com.wanho.qz103.hrsaas.sys.dao.JobDAO;
import com.wanho.qz103.hrsaas.sys.pojos.Employee;
import com.wanho.qz103.hrsaas.sys.pojos.Job;
import com.wanho.qz103.hrsaas.sys.service.EmployeeService;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeDAO employeeDAO ;
    @Autowired
    private JobDAO jobDAO ;
    @Override
    public Employee getPersonalInfo(String userId) throws ServiceException {
        try {
            return employeeDAO.selectById(userId);
        } catch (DAOException e) {
            e.printStackTrace();
            throw new ServiceException("根据用户id查询员工详情异常！") ;
        }
    }

    @Override
    public Job getJobByUserId(String userId) throws ServiceException {
        try {
            return jobDAO.selectById(userId);
        } catch (DAOException e) {
            e.printStackTrace();
            throw new ServiceException("根据用户id 查询岗位信息异常！") ;
        }
    }

    @Override
    public boolean modify(Employee employee) throws ServiceException {
        try {
            return employeeDAO.update(employee);
        } catch (DAOException e) {
            e.printStackTrace();
            throw new ServiceException("保存用户详情信息异常！") ;
        }
    }
}
